<template>
  <div>
    <div class="boder" v-if="data">
      
      <div class="comments">
        <Parent @replyComment="Commentrelpy" :deep="deep !=0 ?deep-1 :0" :data="data.parent" v-if="data.parent" />
        <div class="ct">
          <div class="left">
            <!-- 楼层 -->
            {{deep}}
            <i>{{data.user.nickname}}</i>
            <span>2小时前</span>
          </div>
          <div class="right" @click="relpy">回复</div>
        </div>
        <div class="cf">
          <p>{{data.content}}</p>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  props: ['data', 'deep'],
  name: 'Parent',
  methods: {
    // 点击回复事件
    relpy(){
      // 传值
      this.$emit('replyComment',{
        id:this.data.id,
        nickname:this.data.user.nickname
      })
    },
    // 监听回复事件
    Commentrelpy(obj){
      // 将接收到的值再次传出去
      this.$emit('replyComment',obj)
    }
  },
}
</script>
<style lang="less" scoped>
.parent {
  border: 1px solid red;
  padding: 10px;
}
.comments {
  padding: 4.167vw;
  margin: 0 4.167vw;
  border: 1px solid #ccc;

  .ct {
    display: flex;
    justify-content: space-between;
    .left {
      font-size: 3.333vw;
      i {
        font-style: normal;
        font-size: 3.889vw;
        margin: 0 4.167vw 0 1.389vw;
      }
      span {
        // font-size: 3.333vw;
        color: #707070;
      }
    }
    .right {
      font-size: 3.333vw;
      color: #707070;
    }
  }
  .cf {
    padding-top: 4.167vw;
    font-size: 3.889vw;
  }
}
</style>